﻿using System.Collections.ObjectModel;

namespace Library
{
    public class ScreenCollection : KeyedCollection<string, Screen>
    {
        protected override string GetKeyForItem(Screen item)
        {
            return item.Name;
        }

        protected override void RemoveItem(int index)
        {
            Screen screen = Items[index];

            if (Engine.DefScreen == screen)
                Engine.DefScreen = Engine.BgScreen;
            base.RemoveItem(index);
        }
    }
}